<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

$this->title = '角色管理';
$this->params['breadcrumbs'][] = '管理员设置';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="nav-tabs-custom">
    <?= $this->render('_tab_menu') ?>
    <div class="box">
        <div class="box-body">
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'filterPosition' => GridView::FILTER_POS_FOOTER,
            'layout' => '{items}{summary}{pager}',
            'columns' => [
                //['class' => 'yii\grid\SerialColumn'],

                [
                    'attribute' => 'name',
                    'label' => '角色名称'
                ],
                [
                    'attribute' => 'description',
                    'label' => '描述'
                ],
                [
                    'attribute' => 'createdAt',
                    'label' => '添加时间',
                    'value' => function($data) {
                        return date('Y-m-d H:i:s', $data->createdAt);
                    }
                ],
                [
                    'attribute' => 'updatedAt',
                    'label' => '更新时间',
                    'value' => function($data) {
                        return date('Y-m-d H:i:s', $data->updatedAt);
                    }
                ],

                [
                    'class' => 'app\core\lib\ActionColumn',
                    'template'  =>  '{update} {auth} {delete}',
                    'headerOptions' => ['width' => '300'],
                    'buttons' => [
                        'auth' => function($url, $model, $key){
                            return Html::a('<span class="fa fa-user"></span> 权限',
                                ['auth', 'id'=>$key], //1Product 2Cuntomer 3News
                                [
                                    'class' => 'btn btn-success btn-xs btn-images',
                                    'data-url' => Yii::$app->urlManager->createUrl(['admin/images/index', 'target_id' => $key, 'type'=>1])
                                ]
                            );
                        }
                    ]
                ],
            ],
        ]); ?>

        </div>
    </div>
</div>
